home *** CD-ROM | disk | FTP | other *** search
/ Die Ultimative Software-P…i Collection 1996 & 1997 / Die Ultimative Software-Pakete CD-ROM fur Atari Collection 1996 & 1997.iso / g / gnu_c / info.lzh / INFO / GCC_INFO.7 < prev    next >
Encoding:
GNU Info File  |  1993-10-21  |  51.1 KB  |  1,180 lines

  1. This is Info file gcc.info, produced by Makeinfo-1.54 from the input
  2. file gcc.texi.
  3.  
  4.    This file documents the use and the internals of the GNU compiler.
  5.  
  6.    Copyright (C) 1988, 1989, 1992, 1993 Free Software Foundation, Inc.
  7.  
  8.    Permission is granted to make and distribute verbatim copies of this
  9. manual provided the copyright notice and this permission notice are
  10. preserved on all copies.
  11.  
  12.    Permission is granted to copy and distribute modified versions of
  13. this manual under the conditions for verbatim copying, provided also
  14. that the sections entitled "GNU General Public License" and "Protect
  15. Your Freedom--Fight `Look And Feel'" are included exactly as in the
  16. original, and provided that the entire resulting derived work is
  17. distributed under the terms of a permission notice identical to this
  18. one.
  19.  
  20.    Permission is granted to copy and distribute translations of this
  21. manual into another language, under the above conditions for modified
  22. versions, except that the sections entitled "GNU General Public
  23. License" and "Protect Your Freedom--Fight `Look And Feel'", and this
  24. permission notice, may be included in translations approved by the Free
  25. Software Foundation instead of in the original English.
  26.  
  27. File: gcc.info,  Node: Naming Results,  Next: Min and Max,  Up: C++ Extensions
  28.  
  29. Named Return Values in C++
  30. ==========================
  31.  
  32.    GNU C++ extends the function-definition syntax to allow you to
  33. specify a name for the result of a function outside the body of the
  34. definition, in C++ programs:
  35.  
  36.      TYPE
  37.      FUNCTIONNAME (ARGS) return RESULTNAME;
  38.      {
  39.        ...
  40.        BODY
  41.        ...
  42.      }
  43.  
  44.    You can use this feature to avoid an extra constructor call when a
  45. function result has a class type.  For example, consider a function
  46. `m', declared as `X v = m ();', whose result is of class `X':
  47.  
  48.      X
  49.      m ()
  50.      {
  51.        X b;
  52.        b.a = 23;
  53.        return b;
  54.      }
  55.  
  56.    Although `m' appears to have no arguments, in fact it has one
  57. implicit argument: the address of the return value.  At invocation, the
  58. address of enough space to hold `v' is sent in as the implicit argument.
  59. Then `b' is constructed and its `a' field is set to the value 23.
  60. Finally, a copy constructor (a constructor of the form `X(X&)') is
  61. applied to `b', with the (implicit) return value location as the
  62. target, so that `v' is now bound to the return value.
  63.  
  64.    But this is wasteful.  The local `b' is declared just to hold
  65. something that will be copied right out.  While a compiler that
  66. combined an "elision" algorithm with interprocedural data flow analysis
  67. could conceivably eliminate all of this, it is much more practical to
  68. allow you to assist the compiler in generating efficient code by
  69. manipulating the return value explicitly, thus avoiding the local
  70. variable and copy constructor altogether.
  71.  
  72.    Using the extended GNU C++ function-definition syntax, you can avoid
  73. the temporary allocation and copying by naming `r' as your return value
  74. as the outset, and assigning to its `a' field directly:
  75.  
  76.      X
  77.      m () return r;
  78.      {
  79.        r.a = 23;
  80.      }
  81.  
  82. The declaration of `r' is a standard, proper declaration, whose effects
  83. are executed *before* any of the body of `m'.
  84.  
  85.    Functions of this type impose no additional restrictions; in
  86. particular, you can execute `return' statements, or return implicitly by
  87. reaching the end of the function body ("falling off the edge").  Cases
  88. like
  89.  
  90.      X
  91.      m () return r (23);
  92.      {
  93.        return;
  94.      }
  95.  
  96. (or even `X m () return r (23); { }') are unambiguous, since the return
  97. value `r' has been initialized in either case.  The following code may
  98. be hard to read, but also works predictably:
  99.  
  100.      X
  101.      m () return r;
  102.      {
  103.        X b;
  104.        return b;
  105.      }
  106.  
  107.    The return value slot denoted by `r' is initialized at the outset,
  108. but the statement `return b;' overrides this value.  The compiler deals
  109. with this by destroying `r' (calling the destructor if there is one, or
  110. doing nothing if there is not), and then reinitializing `r' with `b'.
  111.  
  112.    This extension is provided primarily to help people who use
  113. overloaded operators, where there is a great need to control not just
  114. the arguments, but the return values of functions.  For classes where
  115. the copy constructor incurs a heavy performance penalty (especially in
  116. the common case where there is a quick default constructor), this is a
  117. major savings.  The disadvantage of this extension is that you do not
  118. control when the default constructor for the return value is called: it
  119. is always called at the beginning.
  120.  
  121. File: gcc.info,  Node: Min and Max,  Next: Destructors and Goto,  Prev: Naming Results,  Up: C++ Extensions
  122.  
  123. Minimum and Maximum Operators in C++
  124. ====================================
  125.  
  126.    It is very convenient to have operators which return the "minimum"
  127. or the "maximum" of two arguments.  In GNU C++ (but not in GNU C),
  128.  
  129. `A <? B'
  130.      is the "minimum", returning the smaller of the numeric values A
  131.      and B;
  132.  
  133. `A >? B'
  134.      is the "maximum", returning the larger of the numeric values A and
  135.      B.
  136.  
  137.    These operations are not primitive in ordinary C++, since you can
  138. use a macro to return the minimum of two things in C++, as in the
  139. following example.
  140.  
  141.      #define MIN(X,Y) ((X) < (Y) ? : (X) : (Y))
  142.  
  143. You might then use `int min = MIN (i, j);' to set MIN to the minimum
  144. value of variables I and J.
  145.  
  146.    However, side effects in `X' or `Y' may cause unintended behavior.
  147. For example, `MIN (i++, j++)' will fail, incrementing the smaller
  148. counter twice.  A GNU C extension allows you to write safe macros that
  149. avoid this kind of problem (*note Naming an Expression's Type: Naming
  150. Types.).  However, writing `MIN' and `MAX' as macros also forces you to
  151. use function-call notation notation for a fundamental arithmetic
  152. operation.  Using GNU C++ extensions, you can write `int min = i <? j;'
  153. instead.
  154.  
  155.    Since `<?' and `>?' are built into the compiler, they properly
  156. handle expressions with side-effects;  `int min = i++ <? j++;' works
  157. correctly.
  158.  
  159. File: gcc.info,  Node: Destructors and Goto,  Next: C++ Interface,  Prev: Min and Max,  Up: C++ Extensions
  160.  
  161. `goto' and Destructors in GNU C++
  162. =================================
  163.  
  164.    In C++ programs, you can safely use the `goto' statement.  When you
  165. use it to exit a block which contains aggregates requiring destructors,
  166. the destructors will run before the `goto' transfers control.  (In ANSI
  167. C++, `goto' is restricted to targets within the current block.)
  168.  
  169.    The compiler still forbids using `goto' to *enter* a scope that
  170. requires constructors.
  171.  
  172. File: gcc.info,  Node: C++ Interface,  Prev: Destructors and Goto,  Up: C++ Extensions
  173.  
  174. Declarations and Definitions in One Header
  175. ==========================================
  176.  
  177.    C++ object definitions can be quite complex.  In principle, your
  178. source code will need two kinds of things for each object that you use
  179. across more than one source file.  First, you need an "interface"
  180. specification, describing its structure with type declarations and
  181. function prototypes.  Second, you need the "implementation" itself.  It
  182. can be tedious to maintain a separate interface description in a header
  183. file, in parallel to the actual implementation.  It is also dangerous,
  184. since separate interface and implementation definitions may not remain
  185. parallel.
  186.  
  187.    With GNU C++, you can use a single header file for both purposes.
  188.  
  189.      *Warning:* The mechanism to specify this is in transition.  For the
  190.      nonce, you must use one of two `#pragma' commands; in a future
  191.      release of GNU C++, an alternative mechanism will make these
  192.      `#pragma' commands unnecessary.
  193.  
  194.    The header file contains the full definitions, but is marked with
  195. `#pragma interface' in the source code.  This allows the compiler to
  196. use the header file only as an interface specification when ordinary
  197. source files incorporate it with `#include'.  In the single source file
  198. where the full implementation belongs, you can use either a naming
  199. convention or `#pragma implementation' to indicate this alternate use
  200. of the header file.
  201.  
  202. `#pragma interface'
  203.      Use this directive in *header files* that define object classes,
  204.      to save space in most of the object files that use those classes.
  205.      Normally, local copies of certain information (backup copies of
  206.      inline member functions, debugging information, and the internal
  207.      tables that implement virtual functions) must be kept in each
  208.      object file that includes class definitions.  You can use this
  209.      pragma to avoid such duplication.  When a header file containing
  210.      `#pragma interface' is included in a compilation, this auxiliary
  211.      information will not be generated (unless the main input source
  212.      file itself uses `#pragma implementation').  Instead, the object
  213.      files will contain references to be resolved at link time.
  214.  
  215. `#pragma implementation'
  216. `#pragma implementation "OBJECTS.h"'
  217.      Use this pragma in a *main input file*, when you want full output
  218.      from included header files to be generated (and made globally
  219.      visible).  The included header file, in turn, should use `#pragma
  220.      interface'.  Backup copies of inline member functions, debugging
  221.      information, and the internal tables used to implement virtual
  222.      functions are all generated in implementation files.
  223.  
  224.      `#pragma implementation' is *implied* whenever the basename(1) of
  225.      your source file matches the basename of a header file it
  226.      includes.  There is no way to turn this off (other than using a
  227.      different name for one of the two files).  In the same vein, if
  228.      you use `#pragma implementation' with no argument, it applies to an
  229.      include file with the same basename as your source file.  For
  230.      example, in `allclass.cc', `#pragma implementation' by itself is
  231.      equivalent to `#pragma implementation "allclass.h"'; but even if
  232.      you do not say `#pragma implementation' at all, `allclass.h' is
  233.      treated as an implementation file whenever you include it from
  234.      `allclass.cc'.
  235.  
  236.      If you use an explicit `#pragma implementation', it must appear in
  237.      your source file *before* you include the affected header files.
  238.  
  239.      Use the string argument if you want a single implementation file to
  240.      include code from multiple header files.  (You must also use
  241.      `#include' to include the header file; `#pragma implementation'
  242.      only specifies how to use the file--it doesn't actually include
  243.      it.)
  244.  
  245.      There is no way to split up the contents of a single header file
  246.      into multiple implementation files.
  247.  
  248.    `#pragma implementation' and `#pragma interface' also have an effect
  249. on function inlining.
  250.  
  251.    If you define a class in a header file marked with `#pragma
  252. interface', the effect on a function defined in that class is similar to
  253. an explicit `extern' declaration--the compiler emits no code at all to
  254. define an independent version of the function.  Its definition is used
  255. only for inlining with its callers.
  256.  
  257.    Conversely, when you include the same header file in a main source
  258. file that declares it as `#pragma implementation', the compiler emits
  259. code for the function itself; this defines a version of the function
  260. that can be found via pointers (or by callers compiled without
  261. inlining).
  262.  
  263.    ---------- Footnotes ----------
  264.  
  265.    (1)  A file's "basename" is the name stripped of all leading path
  266. information and of trailing suffixes, such as `.h' or `.C' or `.cc'.
  267.  
  268. File: gcc.info,  Node: Trouble,  Next: Bugs,  Prev: C++ Extensions,  Up: Top
  269.  
  270. Known Causes of Trouble with GNU CC
  271. ***********************************
  272.  
  273.    This section describes known problems that affect users of GNU CC.
  274. Most of these are not GNU CC bugs per se--if they were, we would fix
  275. them.  But the result for a user may be like the result of a bug.
  276.  
  277.    Some of these problems are due to bugs in other software, some are
  278. missing features that are too much work to add, and some are places
  279. where people's opinions differ as to what is best.
  280.  
  281. * Menu:
  282.  
  283. * Actual Bugs::              Bugs we will fix later.
  284. * Installation Problems::     Problems that manifest when you install GNU CC.
  285. * Cross-Compiler Problems::   Common problems of cross compiling with GNU CC.
  286. * Interoperation::      Problems using GNU CC with other compilers,
  287.                and with certain linkers, assemblers and debuggers.
  288. * External Bugs::    Problems compiling certain programs.
  289. * Incompatibilities::   GNU CC is incompatible with traditional C.
  290. * Disappointments::     Regrettable things we can't change, but not quite bugs.
  291. * C++ Misunderstandings::     Common misunderstandings with GNU C++.
  292. * Protoize Caveats::    Things to watch out for when using `protoize'.
  293. * Non-bugs::        Things we think are right, but some others disagree.
  294. * Warnings and Errors:: Which problems in your code get warnings,
  295.                          and which get errors.
  296.  
  297. File: gcc.info,  Node: Actual Bugs,  Next: Installation Problems,  Up: Trouble
  298.  
  299. Actual Bugs We Haven't Fixed Yet
  300. ================================
  301.  
  302.    * The `fixincludes' script interacts badly with automounters; if the
  303.      directory of system header files is automounted, it tends to be
  304.      unmounted while `fixincludes' is running.  This would seem to be a
  305.      bug in the automounter.  We don't know any good way to work around
  306.      it.
  307.  
  308.    * Loop unrolling doesn't work properly for certain C++ programs.
  309.      This is because of difficulty in updating the debugging
  310.      information within the loop being unrolled.  We plan to revamp the
  311.      representation of debugging information so that this will work
  312.      properly, but we have not done this in version 2.4 because we
  313.      don't want to delay it any further.
  314.  
  315. File: gcc.info,  Node: Installation Problems,  Next: Cross-Compiler Problems,  Prev: Actual Bugs,  Up: Trouble
  316.  
  317. Installation Problems
  318. =====================
  319.  
  320.    This is a list of problems (and some apparent problems which don't
  321. really mean anything is wrong) that show up during installation of GNU
  322. CC.
  323.  
  324.    * On certain systems, defining certain environment variables such as
  325.      `CC' can interfere with the functioning of `make'.
  326.  
  327.    * If you encounter seemingly strange errors when trying to build the
  328.      compiler in a directory other than the source directory, it could
  329.      be because you have previously configured the compiler in the
  330.      source directory.  Make sure you have done all the necessary
  331.      preparations.  *Note Other Dir::.
  332.  
  333.    * In previous versions of GNU CC, the `gcc' driver program looked for
  334.      `as' and `ld' in various places such as files beginning with
  335.      `/usr/local/lib/gcc-'.  GNU CC version 2 looks for them in the
  336.      directory `/usr/local/lib/gcc-lib/TARGET/VERSION'.
  337.  
  338.      Thus, to use a version of `as' or `ld' that is not the system
  339.      default, for example `gas' or GNU `ld', you must put them in that
  340.      directory (or make links to them from that directory).
  341.  
  342.    * Some commands executed when making the compiler may fail (return a
  343.      non-zero status) and be ignored by `make'.  These failures, which
  344.      are often due to files that were not found, are expected, and can
  345.      safely be ignored.
  346.  
  347.    * It is normal to have warnings in compiling certain files about
  348.      unreachable code and about enumeration type clashes.  These files'
  349.      names begin with `insn-'.  Also, `real.c' may get some warnings
  350.      that you can ignore.
  351.  
  352.    * Sometimes `make' recompiles parts of the compiler when installing
  353.      the compiler.  In one case, this was traced down to a bug in
  354.      `make'.  Either ignore the problem or switch to GNU Make.
  355.  
  356.    * On some 386 systems, building the compiler never finishes because
  357.      `enquire' hangs due to a hardware problem in the motherboard--it
  358.      reports floating point exceptions to the kernel incorrectly.  You
  359.      can install GNU CC except for `float.h' by patching out the
  360.      command to run `enquire'.  You may also be able to fix the problem
  361.      for real by getting a replacement motherboard.  This problem was
  362.      observed in Revision E of the Micronics motherboard, and is fixed
  363.      in Revision F.
  364.  
  365.    * On some 386 systems, GNU CC crashes trying to compile `enquire.c'.
  366.      This happens on machines that don't have a 387 FPU chip.  On 386
  367.      machines, the system kernel is supposed to emulate the 387 when you
  368.      don't have one.  The crash is due to a bug in the emulator.
  369.  
  370.      One of these systems is the Unix from Interactive Systems: 386/ix.
  371.      On this system, an alternate emulator is provided, and it does
  372.      work.  To use it, execute this command as super-user:
  373.  
  374.           ln /etc/emulator.rel1 /etc/emulator
  375.  
  376.      and then reboot the system.  (The default emulator file remains
  377.      present under the name `emulator.dflt'.)
  378.  
  379.      Try using `/etc/emulator.att', if you have such a problem on the
  380.      SCO system.
  381.  
  382.      Another system which has this problem is Esix.  We don't know
  383.      whether it has an alternate emulator that works.
  384.  
  385.    * Sometimes on a Sun 4 you may observe a crash in the program
  386.      `genflags' or `genoutput' while building GNU CC.  This is said to
  387.      be due to a bug in `sh'.  You can probably get around it by running
  388.      `genflags' or `genoutput' manually and then retrying the `make'.
  389.  
  390.    * On Solaris 2, executables of GNU CC version 2.0.2 are commonly
  391.      available, but they have a bug that shows up when compiling current
  392.      versions of GNU CC: undefined symbol errors occur during assembly
  393.      if you use `-g'.
  394.  
  395.      The solution is to compile the current version of GNU CC without
  396.      `-g'.  That makes a working compiler which you can use to recompile
  397.      with `-g'.
  398.  
  399.    * Solaris 2 comes with a number of optional OS packages.  Six of
  400.      these packages are needed to use GNU CC fully.  If you did not
  401.      install all optional packages when installing Solaris, you will
  402.      need to verify that these six packages are installed.
  403.  
  404.      The six packages that GNU CC needs are: `SUNWarc', `SUNWbtool',
  405.      `SUNWesu', `SUNWhea', `SUNWlibm', and `SUNWtoo'.  To check whether
  406.      an optional package is installed, use the `pkginfo' command.  To
  407.      add an optional package, use the `pkgadd' command.  For further
  408.      details, see the Solaris documentation.
  409.  
  410.    * If you use the 1.31 version of the MIPS assembler (such as was
  411.      shipped with Ultrix 3.1), you will need to use the
  412.      -fno-delayed-branch switch when optimizing floating point code.
  413.      Otherwise, the assembler will complain when the GCC compiler fills
  414.      a branch delay slot with a floating point instruction, such as
  415.      add.d.
  416.  
  417.    * Users have reported some problems with version 2.0 of the MIPS
  418.      compiler tools that were shipped with Ultrix 4.1.  Version 2.10
  419.      which came with Ultrix 4.2 seems to work fine.
  420.  
  421.    * Some versions of the MIPS linker will issue an assertion failure
  422.      when linking code that uses `alloca' against shared libraries on
  423.      RISC-OS 5.0, and DEC's OSF/1 systems.  This is a bug in the
  424.      linker, that is supposed to be fixed in future revisions.  To
  425.      protect against this, GCC passes `-non_shared' to the linker
  426.      unless you pass an explicit `-shared' or `-call_shared' switch.
  427.  
  428.    * On System V release 3, you may get this error message while
  429.      linking:
  430.  
  431.           ld fatal: failed to write symbol name SOMETHING
  432.            in strings table for file WHATEVER
  433.  
  434.      This probably indicates that the disk is full or your ULIMIT won't
  435.      allow the file to be as large as it needs to be.
  436.  
  437.      This problem can also result because the kernel parameter `MAXUMEM'
  438.      is too small.  If so, you must regenerate the kernel and make the
  439.      value much larger.  The default value is reported to be 1024; a
  440.      value of 32768 is said to work.  Smaller values may also work.
  441.  
  442.    * On System V, if you get an error like this,
  443.  
  444.           /usr/local/lib/bison.simple: In function `yyparse':
  445.           /usr/local/lib/bison.simple:625: virtual memory exhausted
  446.  
  447.      that too indicates a problem with disk space, ULIMIT, or `MAXUMEM'.
  448.  
  449.    * On the Tower models 4N0 and 6N0, by default a process is not
  450.      allowed to have more than one megabyte of memory.  GNU CC cannot
  451.      compile itself (or many other programs) with `-O' in that much
  452.      memory.
  453.  
  454.      To solve this problem, reconfigure the kernel adding the following
  455.      line to the configuration file:
  456.  
  457.           MAXUMEM = 4096
  458.  
  459.    * On HP 9000 series 300 or 400 running HP-UX release 8.0, there is a
  460.      bug in the assembler that must be fixed before GNU CC can be
  461.      built.  This bug manifests itself during the first stage of
  462.      compilation, while building `libgcc2.a':
  463.  
  464.           _floatdisf
  465.           cc1: warning: `-g' option not supported on this version of GCC
  466.           cc1: warning: `-g1' option not supported on this version of GCC
  467.           ./xgcc: Internal compiler error: program as got fatal signal 11
  468.  
  469.      A patched version of the assembler is available by anonymous ftp
  470.      from `altdorf.ai.mit.edu' as the file
  471.      `archive/cph/hpux-8.0-assembler'.  If you have HP software support,
  472.      the patch can also be obtained directly from HP, as described in
  473.      the following note:
  474.  
  475.           This is the patched assembler, to patch SR#1653-010439, where
  476.           the assembler aborts on floating point constants.
  477.  
  478.           The bug is not really in the assembler, but in the shared
  479.           library version of the function "cvtnum(3c)".  The bug on
  480.           "cvtnum(3c)" is SR#4701-078451.  Anyway, the attached
  481.           assembler uses the archive library version of "cvtnum(3c)"
  482.           and thus does not exhibit the bug.
  483.  
  484.      This patch is also known as PHCO_0800.
  485.  
  486.    * To build GCC for HP PA model 1.1 machines running HP-UX versions
  487.      earlier than 8.07, you have to configure for HP PA model 1.0.
  488.      This is because a bug in the PA configuration that probably will
  489.      be fixed in the next release of the compiler.
  490.  
  491.    * On HP-UX version 9.01 on the HP PA, the HP compiler `cc' does not
  492.      compile GNU CC correctly.  We do not yet know why.  However, GNU CC
  493.      compiled on earlier HP-UX versions works properly on HP-UX 9.01
  494.      and can compile itself properly on 9.01.
  495.  
  496.    * Another assembler problem on the HP PA results in an error message
  497.      like this while compiling part of `libgcc2.a':
  498.  
  499.           as: /usr/tmp/cca08196.s @line#30 [err#1060]
  500.             Argument 1 or 3 in FARG upper
  501.                    - lookahead = RTNVAL=GR
  502.  
  503.      This happens because HP changed the assembler syntax after system
  504.      release 8.02.  GNU CC assumes the newer syntax; if your assembler
  505.      wants the older syntax, comment out this line in the file
  506.      `pa1-hpux.h':
  507.  
  508.           #define HP_FP_ARG_DESCRIPTOR_REVERSED
  509.  
  510.    * Some versions of the Pyramid C compiler are reported to be unable
  511.      to compile GNU CC.  You must use an older version of GNU CC for
  512.      bootstrapping.  One indication of this problem is if you get a
  513.      crash when GNU CC compiles the function `muldi3' in file
  514.      `libgcc2.c'.
  515.  
  516.      You may be able to succeed by getting GNU CC version 1, installing
  517.      it, and using it to compile GNU CC version 2.  The bug in the
  518.      Pyramid C compiler does not seem to affect GNU CC version 1.
  519.  
  520.    * There may be similar problems on System V Release 3.1 on 386
  521.      systems.
  522.  
  523.    * On the Altos 3068, programs compiled with GNU CC won't work unless
  524.      you fix a kernel bug.  This happens using system versions V.2.2
  525.      1.0gT1 and V.2.2 1.0e and perhaps later versions as well.  See the
  526.      file `README.ALTOS'.
  527.  
  528.    * You will get several sorts of compilation and linking errors on the
  529.      we32k if you don't follow the special instructions.  *Note WE32K
  530.      Install::.
  531.  
  532. File: gcc.info,  Node: Cross-Compiler Problems,  Next: Interoperation,  Prev: Installation Problems,  Up: Trouble
  533.  
  534. Cross-Compiler Problems
  535. =======================
  536.  
  537.    You may run into problems with cross compilation on certain machines,
  538. for several reasons.
  539.  
  540.    * Cross compilation can run into trouble for certain machines because
  541.      some target machines' assemblers require floating point numbers to
  542.      be written as *integer* constants in certain contexts.
  543.  
  544.      The compiler writes these integer constants by examining the
  545.      floating point value as an integer and printing that integer,
  546.      because this is simple to write and independent of the details of
  547.      the floating point representation.  But this does not work if the
  548.      compiler is running on a different machine with an incompatible
  549.      floating point format, or even a different byte-ordering.
  550.  
  551.      In addition, correct constant folding of floating point values
  552.      requires representing them in the target machine's format.  (The C
  553.      standard does not quite require this, but in practice it is the
  554.      only way to win.)
  555.  
  556.      It is now possible to overcome these problems by defining macros
  557.      such as `REAL_VALUE_TYPE'.  But doing so is a substantial amount of
  558.      work for each target machine.  *Note Cross-compilation::.
  559.  
  560.    * At present, the program `mips-tfile' which adds debug support to
  561.      object files on MIPS systems does not work in a cross compile
  562.      environment.
  563.  
  564. File: gcc.info,  Node: Interoperation,  Next: External Bugs,  Prev: Cross-Compiler Problems,  Up: Trouble
  565.  
  566. Interoperation
  567. ==============
  568.  
  569.    This section lists various difficulties encountered in using GNU C or
  570. GNU C++ together with other compilers or with the assemblers, linkers,
  571. libraries and debuggers on certain systems.
  572.  
  573.    * GNU C normally compiles functions to return small structures and
  574.      unions in registers.  Most other compilers arrange to return them
  575.      just like larger structures and unions.  This can lead to trouble
  576.      when you link together code compiled by different compilers.  To
  577.      avoid the problem, you can use the option `-fpcc-struct-return'
  578.      when compiling with GNU CC.
  579.  
  580.    * GNU C++ does not do name mangling in the same way as other C++
  581.      compilers.  This means that object files compiled with one compiler
  582.      cannot be used with another.
  583.  
  584.      This effect is intentional, to protect you from more subtle
  585.      problems.  Compilers differ as to many internal details of C++
  586.      implementation, including: how class instances are laid out, how
  587.      multiple inheritance is implemented, and how virtual function
  588.      calls are handled.  If the name encoding were made the same, your
  589.      programs would link against libraries provided from other
  590.      compilers--but the programs would then crash when run.
  591.      Incompatible libraries are then detected at link time, rather than
  592.      at run time.
  593.  
  594.    * Older GDB versions sometimes fail to read the output of GNU CC
  595.      version 2.  If you have trouble, get GDB version 4.4 or later.
  596.  
  597.    * DBX rejects some files produced by GNU CC, though it accepts
  598.      similar constructs in output from PCC.  Until someone can supply a
  599.      coherent description of what is valid DBX input and what is not,
  600.      there is nothing I can do about these problems.  You are on your
  601.      own.
  602.  
  603.    * The GNU assembler (GAS) does not support PIC.  To generate PIC
  604.      code, you must use some other assembler, such as `/bin/as'.
  605.  
  606.    * On some BSD systems including some versions of Ultrix, use of
  607.      profiling causes static variable destructors (currently used only
  608.      in C++) not to be run.
  609.  
  610.    * Use of `-I/usr/include' may cause trouble.
  611.  
  612.      Many systems come with header files that won't work with GNU CC
  613.      unless corrected by `fixincludes'.  The corrected header files go
  614.      in a new directory; GNU CC searches this directory before
  615.      `/usr/include'.  If you use `-I/usr/include', this tells GNU CC to
  616.      search `/usr/include' earlier on, before the corrected headers.
  617.      The result is that you get the uncorrected header files.
  618.  
  619.      Instead, you should use these options (when compiling C programs):
  620.  
  621.           -I/usr/local/lib/gcc-lib/TARGET/VERSION/include -I/usr/include
  622.  
  623.      For C++ programs, GNU CC also uses a special directory that
  624.      defines C++ interfaces to standard C subroutines.  This directory
  625.      is meant to be searched *before* other standard include
  626.      directories, so that it takes precedence.  If you are compiling
  627.      C++ programs and specifying include directories explicitly, use
  628.      this option first, then the two options above:
  629.  
  630.           -I/usr/local/lib/g++-include
  631.  
  632.    * On a Sparc, GNU CC aligns all values of type `double' on an 8-byte
  633.      boundary, and it expects every `double' to be so aligned.  The Sun
  634.      compiler usually gives `double' values 8-byte alignment, with one
  635.      exception: function arguments of type `double' may not be aligned.
  636.  
  637.      As a result, if a function compiled with Sun CC takes the address
  638.      of an argument of type `double' and passes this pointer of type
  639.      `double *' to a function compiled with GNU CC, dereferencing the
  640.      pointer may cause a fatal signal.
  641.  
  642.      One way to solve this problem is to compile your entire program
  643.      with GNU CC.  Another solution is to modify the function that is
  644.      compiled with Sun CC to copy the argument into a local variable;
  645.      local variables are always properly aligned.  A third solution is
  646.      to modify the function that uses the pointer to dereference it via
  647.      the following function `access_double' instead of directly with
  648.      `*':
  649.  
  650.           inline double
  651.           access_double (double *unaligned_ptr)
  652.           {
  653.             union d2i { double d; int i[2]; };
  654.           
  655.             union d2i *p = (union d2i *) unaligned_ptr;
  656.             union d2i u;
  657.           
  658.             u.i[0] = p->i[0];
  659.             u.i[1] = p->i[1];
  660.           
  661.             return u.d;
  662.           }
  663.  
  664.      Storing into the pointer can be done likewise with the same union.
  665.  
  666.    * On Solaris, the `malloc' function in the `libmalloc.a' library may
  667.      allocate memory that is only 4 byte aligned.  Since GNU CC on the
  668.      Sparc assumes that doubles are 8 byte aligned, this may result in a
  669.      fatal signal if doubles are stored in memory allocated by the
  670.      `libmalloc.a' library.
  671.  
  672.      The solution is to not use the `libmalloc.a' library.  Use instead
  673.      `malloc' and related functions from `libc.a'; they do not have
  674.      this problem.
  675.  
  676.    * On a Sun, linking using GNU CC fails to find a shared library and
  677.      reports that the library doesn't exist at all.
  678.  
  679.      This happens if you are using the GNU linker, because it does only
  680.      static linking and looks only for unshared libraries.  If you have
  681.      a shared library with no unshared counterpart, the GNU linker
  682.      won't find anything.
  683.  
  684.      We hope to make a linker which supports Sun shared libraries, but
  685.      please don't ask when it will be finished--we don't know.
  686.  
  687.    * Sun forgot to include a static version of `libdl.a' with some
  688.      versions of SunOS (mainly 4.1).  This results in undefined symbols
  689.      when linking static binaries (that is, if you use `-static').  If
  690.      you see undefined symbols `_dlclose', `_dlsym' or `_dlopen' when
  691.      linking, compile and link against the file `mit/util/misc/dlsym.c'
  692.      from the MIT version of X windows.
  693.  
  694.    * On the HP PA machine, ADB sometimes fails to work on functions
  695.      compiled with GNU CC.  Specifically, it fails to work on functions
  696.      that use `alloca' or variable-size arrays.  This is because GNU CC
  697.      doesn't generate HP-UX unwind descriptors for such functions.  It
  698.      may even be impossible to generate them.
  699.  
  700.    * Debugging (`-g') is not supported on the HP PA machine, unless you
  701.      use the preliminary GNU tools (*note Installation::.).
  702.  
  703.    * The HP-UX linker has a bug which can cause programs which make use
  704.      of `const' variables to fail in unusual ways.  If your program
  705.      makes use of global `const' variables, we suggest you compile with
  706.      the following additional options:
  707.  
  708.           -Dconst="" -D__const="" -D__const__="" -fwritable-strings
  709.  
  710.      This will force the `const' variables into the DATA subspace which
  711.      will avoid the linker bug.
  712.  
  713.      Another option one might use to work around this problem is
  714.      `-mkernel'.  `-mkernel' changes how the address of variables is
  715.      computed to a sequence less likely to tickle the HP-UX linker bug.
  716.  
  717.      We hope to work around this problem in GNU CC 2.4, if HP does not
  718.      fix it.
  719.  
  720.    * Taking the address of a label may generate errors from the HP-UX
  721.      PA assembler.  GAS for the PA does not have this problem.
  722.  
  723.    * GNU CC produced code will not yet link against HP-UX 8.0 shared
  724.      libraries.  We expect to fix this problem in GNU CC 2.4.
  725.  
  726.    * GNU CC compiled code sometimes emits warnings from the HP-UX
  727.      assembler of the form:
  728.  
  729.           (warning) Use of GR3 when
  730.             frame >= 8192 may cause conflict.
  731.  
  732.      These warnings are harmless and can be safely ignored.
  733.  
  734.    * The current version of the assembler (`/bin/as') for the RS/6000
  735.      has certain problems that prevent the `-g' option in GCC from
  736.      working.  Note that `Makefile.in' uses `-g' by default when
  737.      compiling `libgcc2.c'.
  738.  
  739.      IBM has produced a fixed version of the assembler.  The upgraded
  740.      assembler unfortunately was not included in any of the AIX 3.2
  741.      update PTF releases (3.2.2, 3.2.3, or 3.2.3e).  Users of AIX 3.1
  742.      should request PTF U403044 from IBM and users of AIX 3.2 should
  743.      request PTF U416277.  See the file `README.RS6000' for more
  744.      details on these updates.
  745.  
  746.      You can test for the presense of a fixed assembler by using the
  747.      command
  748.  
  749.           as -u < /dev/null
  750.  
  751.      If the command exits normally, the assembler fix already is
  752.      installed.  If the assembler complains that "-u" is an unknown
  753.      flag, you need to order the fix.
  754.  
  755.    * On the IBM RS/6000, compiling code of the form
  756.  
  757.           extern int foo;
  758.           
  759.           ... foo ...
  760.           
  761.           static int foo;
  762.  
  763.      will cause the linker to report an undefined symbol `foo'.
  764.      Although this behavior differs from most other systems, it is not a
  765.      bug because redefining an `extern' variable as `static' is
  766.      undefined in ANSI C.
  767.  
  768.    * AIX on the RS/6000 provides support (NLS) for environments outside
  769.      of the United States.  Compilers and assemblers use NLS to support
  770.      locale-specific representations of various objects including
  771.      floating-point numbers ("." vs "," for separating decimal
  772.      fractions).  There have been problems reported where the library
  773.      linked with GCC does not produce the same floating-point formats
  774.      that the assembler accepts.  If you have this problem, set the
  775.      LANG environment variable to "C" or "En_US".
  776.  
  777.    * There is an assembler bug in versions of DG/UX prior to 5.4.2.01
  778.      that occurs when the `fldcr' instruction is used.  GNU CC uses
  779.      `fldcr' on the 88100 to serialize volatile memory references.  Use
  780.      the option `-fno-serialize-volatile' if your version of the
  781.      assembler has this bug.
  782.  
  783.    * On VMS, GAS versions 1.38.1 and earlier may cause spurious warning
  784.      messages from the linker.  These warning messages complain of
  785.      mismatched psect attributes.  You can ignore them.  *Note VMS
  786.      Install::.
  787.  
  788.    * On NewsOS version 3, if you include both of the files `stddef.h'
  789.      and `sys/types.h', you get an error because there are two typedefs
  790.      of `size_t'.  You should change `sys/types.h' by adding these
  791.      lines around the definition of `size_t':
  792.  
  793.           #ifndef _SIZE_T
  794.           #define _SIZE_T
  795.           ACTUAL TYPEDEF HERE
  796.           #endif
  797.  
  798.    * On the Alliant, the system's own convention for returning
  799.      structures and unions is unusual, and is not compatible with GNU
  800.      CC no matter what options are used.
  801.  
  802.    * On the IBM RT PC, the MetaWare HighC compiler (hc) uses yet another
  803.      convention for structure and union returning.  Use
  804.      `-mhc-struct-return' to tell GNU CC to use a convention compatible
  805.      with it.
  806.  
  807.    * On Ultrix, the Fortran compiler expects registers 2 through 5 to
  808.      be saved by function calls.  However, the C compiler uses
  809.      conventions compatible with BSD Unix: registers 2 through 5 may be
  810.      clobbered by function calls.
  811.  
  812.      GNU CC uses the same convention as the Ultrix C compiler.  You can
  813.      use these options to produce code compatible with the Fortran
  814.      compiler:
  815.  
  816.           -fcall-saved-r2 -fcall-saved-r3 -fcall-saved-r4 -fcall-saved-r5
  817.  
  818.    * On the WE32k, you may find that programs compiled with GNU CC do
  819.      not work with the standard shared C ilbrary.  You may need to link
  820.      with the ordinary C compiler.  If you do so, you must specify the
  821.      following options:
  822.  
  823.           -L/usr/local/lib/gcc-lib/we32k-att-sysv/2.4 -lgcc -lc_s
  824.  
  825.      The first specifies where to find the library `libgcc.a' specified
  826.      with the `-lgcc' option.
  827.  
  828.      GNU CC does linking by invoking `ld', just as `cc' does, and there
  829.      is no reason why it *should* matter which compilation program you
  830.      use to invoke `ld'.  If someone tracks this problem down, it can
  831.      probably be fixed easily.
  832.  
  833. File: gcc.info,  Node: External Bugs,  Next: Incompatibilities,  Prev: Interoperation,  Up: Trouble
  834.  
  835. Problems Compiling Certain Programs
  836. ===================================
  837.  
  838.    * Parse errors may occur compiling X11 on a Decstation running
  839.      Ultrix 4.2 because of problems in DEC's versions of the X11 header
  840.      files `X11/Xlib.h' and `X11/Xutil.h'.  People recommend adding
  841.      `-I/usr/include/mit' to use the MIT versions of the header files,
  842.      using the `-traditional' switch to turn off ANSI C, or fixing the
  843.      header files by adding this:
  844.  
  845.           #ifdef __STDC__
  846.           #define NeedFunctionPrototypes 0
  847.           #endif
  848.  
  849. File: gcc.info,  Node: Incompatibilities,  Next: Disappointments,  Prev: External Bugs,  Up: Trouble
  850.  
  851. Incompatibilities of GNU CC
  852. ===========================
  853.  
  854.    There are several noteworthy incompatibilities between GNU C and most
  855. existing (non-ANSI) versions of C.  The `-traditional' option
  856. eliminates many of these incompatibilities, *but not all*, by telling
  857. GNU C to behave like the other C compilers.
  858.  
  859.    * GNU CC normally makes string constants read-only.  If several
  860.      identical-looking string constants are used, GNU CC stores only one
  861.      copy of the string.
  862.  
  863.      One consequence is that you cannot call `mktemp' with a string
  864.      constant argument.  The function `mktemp' always alters the string
  865.      its argument points to.
  866.  
  867.      Another consequence is that `sscanf' does not work on some systems
  868.      when passed a string constant as its format control string or
  869.      input.  This is because `sscanf' incorrectly tries to write into
  870.      the string constant.  Likewise `fscanf' and `scanf'.
  871.  
  872.      The best solution to these problems is to change the program to use
  873.      `char'-array variables with initialization strings for these
  874.      purposes instead of string constants.  But if this is not possible,
  875.      you can use the `-fwritable-strings' flag, which directs GNU CC to
  876.      handle string constants the same way most C compilers do.
  877.      `-traditional' also has this effect, among others.
  878.  
  879.    * `-2147483648' is positive.
  880.  
  881.      This is because 2147483648 cannot fit in the type `int', so
  882.      (following the ANSI C rules) its data type is `unsigned long int'.
  883.      Negating this value yields 2147483648 again.
  884.  
  885.    * GNU CC does not substitute macro arguments when they appear inside
  886.      of string constants.  For example, the following macro in GNU CC
  887.  
  888.           #define foo(a) "a"
  889.  
  890.      will produce output `"a"' regardless of what the argument A is.
  891.  
  892.      The `-traditional' option directs GNU CC to handle such cases
  893.      (among others) in the old-fashioned (non-ANSI) fashion.
  894.  
  895.    * When you use `setjmp' and `longjmp', the only automatic variables
  896.      guaranteed to remain valid are those declared `volatile'.  This is
  897.      a consequence of automatic register allocation.  Consider this
  898.      function:
  899.  
  900.           jmp_buf j;
  901.           
  902.           foo ()
  903.           {
  904.             int a, b;
  905.           
  906.             a = fun1 ();
  907.             if (setjmp (j))
  908.               return a;
  909.           
  910.             a = fun2 ();
  911.             /* `longjmp (j)' may occur in `fun3'. */
  912.             return a + fun3 ();
  913.           }
  914.  
  915.      Here `a' may or may not be restored to its first value when the
  916.      `longjmp' occurs.  If `a' is allocated in a register, then its
  917.      first value is restored; otherwise, it keeps the last value stored
  918.      in it.
  919.  
  920.      If you use the `-W' option with the `-O' option, you will get a
  921.      warning when GNU CC thinks such a problem might be possible.
  922.  
  923.      The `-traditional' option directs GNU C to put variables in the
  924.      stack by default, rather than in registers, in functions that call
  925.      `setjmp'.  This results in the behavior found in traditional C
  926.      compilers.
  927.  
  928.    * Programs that use preprocessor directives in the middle of macro
  929.      arguments do not work with GNU CC.  For example, a program like
  930.      this will not work:
  931.  
  932.           foobar (
  933.           #define luser
  934.                   hack)
  935.  
  936.      ANSI C does not permit such a construct.  It would make sense to
  937.      support it when `-traditional' is used, but it is too much work to
  938.      implement.
  939.  
  940.    * Declarations of external variables and functions within a block
  941.      apply only to the block containing the declaration.  In other
  942.      words, they have the same scope as any other declaration in the
  943.      same place.
  944.  
  945.      In some other C compilers, a `extern' declaration affects all the
  946.      rest of the file even if it happens within a block.
  947.  
  948.      The `-traditional' option directs GNU C to treat all `extern'
  949.      declarations as global, like traditional compilers.
  950.  
  951.    * In traditional C, you can combine `long', etc., with a typedef
  952.      name, as shown here:
  953.  
  954.           typedef int foo;
  955.           typedef long foo bar;
  956.  
  957.      In ANSI C, this is not allowed: `long' and other type modifiers
  958.      require an explicit `int'.  Because this criterion is expressed by
  959.      Bison grammar rules rather than C code, the `-traditional' flag
  960.      cannot alter it.
  961.  
  962.    * PCC allows typedef names to be used as function parameters.  The
  963.      difficulty described immediately above applies here too.
  964.  
  965.    * PCC allows whitespace in the middle of compound assignment
  966.      operators such as `+='.  GNU CC, following the ANSI standard, does
  967.      not allow this.  The difficulty described immediately above
  968.      applies here too.
  969.  
  970.    * GNU CC complains about unterminated character constants inside of
  971.      preprocessor conditionals that fail.  Some programs have English
  972.      comments enclosed in conditionals that are guaranteed to fail; if
  973.      these comments contain apostrophes, GNU CC will probably report an
  974.      error.  For example, this code would produce an error:
  975.  
  976.           #if 0
  977.           You can't expect this to work.
  978.           #endif
  979.  
  980.      The best solution to such a problem is to put the text into an
  981.      actual C comment delimited by `/*...*/'.  However, `-traditional'
  982.      suppresses these error messages.
  983.  
  984.    * Many user programs contain the declaration `long time ();'.  In the
  985.      past, the system header files on many systems did not actually
  986.      declare `time', so it did not matter what type your program
  987.      declared it to return.  But in systems with ANSI C headers, `time'
  988.      is declared to return `time_t', and if that is not the same as
  989.      `long', then `long time ();' is erroneous.
  990.  
  991.      The solution is to change your program to use `time_t' as the
  992.      return type of `time'.
  993.  
  994.    * When compiling functions that return `float', PCC converts it to a
  995.      double.  GNU CC actually returns a `float'.  If you are concerned
  996.      with PCC compatibility, you should declare your functions to return
  997.      `double'; you might as well say what you mean.
  998.  
  999.    * When compiling functions that return structures or unions, GNU CC
  1000.      output code normally uses a method different from that used on most
  1001.      versions of Unix.  As a result, code compiled with GNU CC cannot
  1002.      call a structure-returning function compiled with PCC, and vice
  1003.      versa.
  1004.  
  1005.      The method used by GNU CC is as follows: a structure or union
  1006.      which is 1, 2, 4 or 8 bytes long is returned like a scalar.  A
  1007.      structure or union with any other size is stored into an address
  1008.      supplied by the caller (usually in a special, fixed register, but
  1009.      on some machines it is passed on the stack).  The
  1010.      machine-description macros `STRUCT_VALUE' and
  1011.      `STRUCT_INCOMING_VALUE' tell GNU CC where to pass this address.
  1012.  
  1013.      By contrast, PCC on most target machines returns structures and
  1014.      unions of any size by copying the data into an area of static
  1015.      storage, and then returning the address of that storage as if it
  1016.      were a pointer value.  The caller must copy the data from that
  1017.      memory area to the place where the value is wanted.  GNU CC does
  1018.      not use this method because it is slower and nonreentrant.
  1019.  
  1020.      On some newer machines, PCC uses a reentrant convention for all
  1021.      structure and union returning.  GNU CC on most of these machines
  1022.      uses a compatible convention when returning structures and unions
  1023.      in memory, but still returns small structures and unions in
  1024.      registers.
  1025.  
  1026.      You can tell GNU CC to use a compatible convention for all
  1027.      structure and union returning with the option
  1028.      `-fpcc-struct-return'.
  1029.  
  1030. File: gcc.info,  Node: Disappointments,  Next: C++ Misunderstandings,  Prev: Incompatibilities,  Up: Trouble
  1031.  
  1032. Disappointments and Misunderstandings
  1033. =====================================
  1034.  
  1035.    These problems are perhaps regrettable, but we don't know any
  1036. practical way around them.
  1037.  
  1038.    * Certain local variables aren't recognized by debuggers when you
  1039.      compile with optimization.
  1040.  
  1041.      This occurs because sometimes GNU CC optimizes the variable out of
  1042.      existence.  There is no way to tell the debugger how to compute the
  1043.      value such a variable "would have had", and it is not clear that
  1044.      would be desirable anyway.  So GNU CC simply does not mention the
  1045.      eliminated variable when it writes debugging information.
  1046.  
  1047.      You have to expect a certain amount of disagreement between the
  1048.      executable and your source code, when you use optimization.
  1049.  
  1050.    * Users often think it is a bug when GNU CC reports an error for code
  1051.      like this:
  1052.  
  1053.           int foo (struct mumble *);
  1054.           
  1055.           struct mumble { ... };
  1056.           
  1057.           int foo (struct mumble *x)
  1058.           { ... }
  1059.  
  1060.      This code really is erroneous, because the scope of `struct
  1061.      mumble' in the prototype is limited to the argument list
  1062.      containing it.  It does not refer to the `struct mumble' defined
  1063.      with file scope immediately below--they are two unrelated types
  1064.      with similar names in different scopes.
  1065.  
  1066.      But in the definition of `foo', the file-scope type is used
  1067.      because that is available to be inherited.  Thus, the definition
  1068.      and the prototype do not match, and you get an error.
  1069.  
  1070.      This behavior may seem silly, but it's what the ANSI standard
  1071.      specifies.  It is easy enough for you to make your code work by
  1072.      moving the definition of `struct mumble' above the prototype.
  1073.      It's not worth being incompatible with ANSI C just to avoid an
  1074.      error for the example shown above.
  1075.  
  1076.    * Accesses to bitfields even in volatile objects works by accessing
  1077.      larger objects, such as a byte or a word.  You cannot rely on what
  1078.      size of object is accessed in order to read or write the bitfield;
  1079.      it may even vary for a given bitfield according to the precise
  1080.      usage.
  1081.  
  1082.      If you care about controlling the amount of memory that is
  1083.      accessed, use volatile but do not use bitfields.
  1084.  
  1085.    * GNU CC comes with shell scripts to fix certain known problems in
  1086.      system header files.  They install corrected copies of various
  1087.      header files in a special directory where only GNU CC will
  1088.      normally look for them.  The scripts adapt to various systems by
  1089.      searching all the system header files for the problem cases that
  1090.      we know about.
  1091.  
  1092.      If new system header files are installed, nothing automatically
  1093.      arranges to update the corrected header files.  You will have to
  1094.      reinstall GNU CC to fix the new header files.  More specifically,
  1095.      go to the build directory and delete the files `stmp-fixinc' and
  1096.      `stmp-headers', and the subdirectory `include'; then do `make
  1097.      install' again.
  1098.  
  1099.    * On 68000 systems, you can get paradoxical results if you test the
  1100.      precise values of floating point numbers.  For example, you can
  1101.      find that a floating point value which is not a NaN is not equal
  1102.      to itself.  This results from the fact that the the floating point
  1103.      registers hold a few more bits of precision than fit in a `double'
  1104.      in memory.  Compiled code moves values between memory and floating
  1105.      point registers at its convenience, and moving them into memory
  1106.      truncates them.
  1107.  
  1108.      You can partially avoid this problem by using the `-ffloat-store'
  1109.      option (*note Optimize Options::.).
  1110.  
  1111.    * On the MIPS, variable argument functions using `varargs.h' cannot
  1112.      have a floating point value for the first argument.  The reason
  1113.      for this is that in the absence of a prototype in scope, if the
  1114.      first argument is a floating point, it is passed in a floating
  1115.      point register, rather than an integer register.
  1116.  
  1117.      If the code is rewritten to use the ANSI standard `stdarg.h'
  1118.      method of variable arguments, and the prototype is in scope at the
  1119.      time of the call, everything will work fine.
  1120.  
  1121. File: gcc.info,  Node: C++ Misunderstandings,  Next: Protoize Caveats,  Prev: Disappointments,  Up: Trouble
  1122.  
  1123. Common Misunderstandings with GNU C++
  1124. =====================================
  1125.  
  1126.    C++ is a complex language and an evolving one, and its standard
  1127. definition (the ANSI C++ draft standard) is also evolving.  As a result,
  1128. your C++ compiler may occasionally surprise you, even when its behavior
  1129. is correct.  This section discusses some areas that frequently give
  1130. rise to questions of this sort.
  1131.  
  1132. * Menu:
  1133.  
  1134. * Static Definitions::  Static member declarations are not definitions
  1135. * Temporaries::         Temporaries may vanish before you expect
  1136.  
  1137. File: gcc.info,  Node: Static Definitions,  Next: Temporaries,  Up: C++ Misunderstandings
  1138.  
  1139. Declare *and* Define Static Members
  1140. -----------------------------------
  1141.  
  1142.    When a class has static data members, it is not enough to *declare*
  1143. the static member; you must also *define* it.  For example:
  1144.  
  1145.      class Foo
  1146.      {
  1147.        ...
  1148.        void method();
  1149.        static int bar;
  1150.      };
  1151.  
  1152.    This declaration only establishes that the class `Foo' has an `int'
  1153. named `Foo::bar', and a member function named `Foo::method'.  But you
  1154. still need to define *both* `method' and `bar' elsewhere.  According to
  1155. the draft ANSI standard, you must supply an initializer in one (and
  1156. only one) source file, such as:
  1157.  
  1158.      int Foo::bar = 0;
  1159.  
  1160.    Other C++ compilers may not correctly implement the standard
  1161. behavior.  As a result, when you switch to `g++' from one of these
  1162. compilers, you may discover that a program that appeared to work
  1163. correctly in fact does not conform to the standard: `g++' reports as
  1164. undefined symbols any static data members that lack definitions.
  1165.  
  1166. ə